package com.example.administrator.chinafood.Adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;


/**
 * Created by Administrator on 2017/11/2.
 */

public class MyViewPagerAdapter extends PagerAdapter {

    private int count;
    private List<View> viewLists;

    public MyViewPagerAdapter(int count,List<View> viewLists){
        this.count = count;
        this.viewLists = viewLists;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public int getCount() {
        return count;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewLists.get(position));
        return viewLists.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewLists.get(position));
    }
}
